package com.srzk.youthleagueback.controller;

import com.srzk.youthleagueback.pojo.*;
import com.srzk.youthleagueback.results.Result;
import com.srzk.youthleagueback.service.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/part4")
public class InnovationController {

    @Autowired
    InnovationService service;

    @GetMapping("/innovationList")
    public Result<Map<String,Object>> getList(@RequestParam("user")String user, @RequestParam("year")String year){
        return service.getList(user,year);
    }

    @GetMapping("/innovation")
    public Result<Map<String,Object>> get(@RequestParam("user")String user, @RequestParam("year")String year,@RequestParam("id")Long id){
        return service.get(user,year,id);
    }

    @PostMapping("/innovation")
    public Result<Map<String,Long>> add(Innovation object,MultipartFile[] files){
        return service.add(object,files);
    }

    @DeleteMapping("/innovation")
    public Result<String> delete(@RequestParam("user")String user, @RequestParam("year")String year,@RequestParam("id")Long id){
        return service.delete(user, year, id);
    }

    @PostMapping("/innovationUpdate")
    public Result<String> update(Innovation object,MultipartFile[] files){
        return service.update(object,files);
    }
}
